<!-- 数字竞猜 -->
<template>
    <div class="guess">
        <DialogShare @nextStep="openGuess" :allData="allData" ref="DialogShareRef" />
        <DialogGuess @success="init" ref="DialogGuessRef" :allData="allData" />
        <DialogStatus />
        <DialogRank />
    </div>
</template>

<script setup lang="ts">
import DialogShare from "./DialogShare.vue"
import DialogGuess from "./DialogGuess.vue"
import DialogStatus from "./DialogStatus.vue"
import DialogRank from "./DialogRank.vue"
import { NetPacket } from '@/netBase/NetPacket.ts';
import H5Websocket from "@/net/Net1";
import { MessageEvent2 } from '@/net/MessageEvent2.ts';
import { NetMsgType } from '@/netBase/NetMsgType.ts';
import { onMounted, onUnmounted, ref } from 'vue';

const DialogGuessRef = ref()
const DialogShareRef = ref()

const init = () => {
    const req = NetPacket.req_numbers_betting_info();
    H5Websocket.sendMessageHandler(req);
}

const allData: any = ref({})
const handleInfo = (res: any) => {
    console.error('---', res)
    // res.my_records = [
    //     {
    //         "numbers": 28,
    //         "prize": 888,
    //         "ranking": 1,
    //         "role_id": 12346132,
    //         "roundid": 0,
    //         "status": 0,
    //         "username": "yxcs1017",
    //         bet_time: {}
    //     },
    // ]
    // res.joined = 6
    // res.set_fb = 1
    // res.status = 0
    // res.numbers = 12
    allData.value = res
    // open()
}

const open = () => { // 打开分享说明
    DialogShareRef.value.open()
}
const openGuess = () => { // 打开投注
    DialogGuessRef.value.open()
}

onMounted(() => {
    init()
    MessageEvent2.addMsgEvent(NetMsgType.msgType.msg_notify_numbers_betting_info, handleInfo);
})

onUnmounted(() => {
    MessageEvent2.removeMsgEvent(NetMsgType.msgType.msg_notify_numbers_betting_info, null);
})

defineExpose({
    open
})
</script>

<style lang="less" scoped></style>